USE [TPAI]
GO
/****** Object:  Table [dbo].[SERVICIO_PAQUETE]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SERVICIO_PAQUETE](
	[servicio_id] [numeric](10, 0) NOT NULL,
	[paquete_id] [numeric](10, 0) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[servicio_id] ASC,
	[paquete_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[SERVICIO]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SERVICIO](
	[id] [numeric](10, 0) NOT NULL,
	[nombre] [varchar](60) NOT NULL,
	[tipo] [varchar](60) NOT NULL,
	[unidad] [varchar](60) NOT NULL,
	[costo] [real] NOT NULL,
	[valor_unidad] [real] NOT NULL,
	[unidad_libres] [numeric](10, 0) NOT NULL,
	[descuento] [float] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PLANES]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PLANES](
	[id] [numeric](10, 0) NOT NULL,
	[nombre] [varchar](255) NOT NULL,
	[tipo] [varchar](100) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PLAN_SERVICIOS]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PLAN_SERVICIOS](
	[plan_base_id] [numeric](10, 0) NOT NULL,
	[servicio_id] [numeric](10, 0) NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PLAN_ADICIONAL]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PLAN_ADICIONAL](
	[plan_base_id] [numeric](10, 0) NOT NULL,
	[costo_minuto_exc] [real] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[plan_base_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[LOGGIN]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LOGGIN](
	[usuario] [varchar](20) NULL,
	[pass] [varchar](20) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LINEA]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LINEA](
	[usuario_id] [numeric](10, 0) NOT NULL,
	[plan_id] [numeric](10, 0) NOT NULL,
	[numero] [numeric](14, 0) NOT NULL,
	[fecha_contrato] [date] NOT NULL,
	[tipo] [varchar](30) NOT NULL,
	[nombre_adicional] [varchar](140) NULL,
PRIMARY KEY CLUSTERED 
(
	[numero] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[item_factura]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[item_factura](
	[id] [int] NOT NULL,
	[factura_id] [int] NOT NULL,
	[linea_id] [int] NOT NULL,
	[descripcion] [varchar](255) NOT NULL,
	[subtotal] [real] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facturas]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[facturas](
	[id] [int] NOT NULL,
	[periodo] [varchar](50) NOT NULL,
	[usuario_id] [int] NOT NULL,
	[total] [float] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CONSUMOS]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CONSUMOS](
	[servicio_id] [int] NOT NULL,
	[linea_id] [int] NOT NULL,
	[fecha] [date] NOT NULL,
	[cantidad_consumida] [int] NOT NULL,
	[destino] [varchar](14) NOT NULL,
	[facturado] [int] NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CLIENTE]    Script Date: 11/08/2012 17:50:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CLIENTE](
	[nombre] [varchar](100) NOT NULL,
	[apellido] [varchar](100) NOT NULL,
	[dni] [varchar](14) NOT NULL,
	[domicilio] [varchar](100) NOT NULL,
	[telefono] [varchar](14) NOT NULL,
	[email] [varchar](255) NULL,
	[estado] [char](2) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Default [DF__CLIENTE__email__656C112C]    Script Date: 11/08/2012 17:50:45 ******/
ALTER TABLE [dbo].[CLIENTE] ADD  DEFAULT (NULL) FOR [email]
GO
/****** Object:  Default [DF__CLIENTE__estado__66603565]    Script Date: 11/08/2012 17:50:45 ******/
ALTER TABLE [dbo].[CLIENTE] ADD  DEFAULT (NULL) FOR [estado]
GO
/****** Object:  Default [DF__LINEA__nombre_ad__6C190EBB]    Script Date: 11/08/2012 17:50:45 ******/
ALTER TABLE [dbo].[LINEA] ADD  DEFAULT (NULL) FOR [nombre_adicional]
GO
